package com.iflytek.jcy.supervise.clue.component.httpinterface;

import java.util.Random;

import com.dtflys.forest.callback.AddressSource;
import com.dtflys.forest.http.ForestAddress;
import com.dtflys.forest.http.ForestRequest;

/**
 * @author <a href=mailto:ktyi@iflytek.com>伊开堂</a>
 * @date 2021/12/23
 */
public class HttpAddressSource implements AddressSource {

    @Override
    public ForestAddress getAddress(ForestRequest req) {
        // 定义 3 个 IP 地址
        String[] ipArray = new String[]{"192.168.0.1", "192.168.0.2", "192.168.0.3",};
        // 随机选出其中一个
        Random random = new Random();
        int i = random.nextInt(3);
        String ip = ipArray[i];
        // 返回 Forest 地址对象
        return new ForestAddress(ip, 80);
    }
}
